# -*- coding: UTF-8 -*-
'''
Created on 05.02.2013

@author: p.hess
'''

# Load *all* the classes
# from pi3d import Display
import pi3d as p

class Renderer(object):
    '''
    Handles the graphics like the resolution 
    '''

    def __init__(self, displayX = 0, displayY = 0, pinLayers=None ):
        '''
        Constructor
        
        '''
        self.displayX = displayX
        self.displayY = displayY
        self.DISPLAY = None
        self.loopCounter = 0;
        
    def run(self):        
        if (self.DISPLAY == None) :
            self.createNewDisplay()
        else:
            self.updateDisplay()
        # do object initialisations
        # do shader initialisations
        # main drawing loop
        while self.DISPLAY.loop_running():
            self.doLoop()

    def doLoop(self):
        self.loopCounter += 1;
        # handler drawer spreads
            
    def createNewDisplay(self):
        '''
        uses the fields to create display. 
        '''
        self.DISPLAY = p.Display.create(x=20, y=20)
        self.loopCounter = 0;
        
    def updateDisplay(self):
        self.DISPLAY.destroy();
        self.createNewDisplay();
        